﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="my_pubnews.aspx.cs" Inherits="my_pubnews" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>发布新信息</title>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <style type="text/css">
        body{
            font-size:10pt;
        }
    </style>
    <script language=javascript src="./js/Function.js"></script>
    <script language=javascript src="./js/myCheck.js"></script>
	<script type="text/javascript" src="./jquery/126/jquery-1.2.6.js"></script>	<script type="text/javascript" src="./jquery/jquery.watermarkinput.js"></script>	<script type="text/javascript" src="./jquery/jquery.textLimiter.js"></script>	<script language="javascript" type="text/javascript">        //获取编辑器中HTML内容
        function getEditorHTMLContents(EditorName) { 
            var oEditor = FCKeditorAPI.GetInstance(EditorName); 
            return(oEditor.GetXHTML(true)); 
        }

        // 获取编辑器中文字内容
        function getEditorTextContents(EditorName) { 
            var oEditor = FCKeditorAPI.GetInstance(EditorName); 
            return(oEditor.EditorDocument.body.innerText); 
        }

        // 设置编辑器中内容
        function SetEditorContents(EditorName, ContentStr) { 
            var oEditor = FCKeditorAPI.GetInstance(EditorName); 
            oEditor.SetHTML(ContentStr) ; 
        }

        function article_chk()
        {
			if(CheckText(form1.articletitle,"标题",50)==false) return false;
			if($("#articletitle").val()=="请输入内容标题,最多25个字符!")
			{
				alert("请修改标题!");
				return false;
			}
			
			if(getEditorHTMLContents('fck_content')=='')
			{
				alert("内容不能空!");
				return false;
			}
			return true;
        }
        function article_save()
        {
	        if($("#sendmail").attr('checked'))	        {	            if(confirm('确认要同时发送邮件吗？'))	            {	                mailto();	            }    	        }	        	        $.ajax({	            url:'./ajax/article_save.aspx',	            type:'post',	            data: "userid="+$("#myuid").val()+"&articletitle="+escape($("#articletitle").val())+"&acontent="+escape(getEditorHTMLContents("fck_content")),	            beforeSend:function()	            {	                return article_chk();	            },	            error:function()	            {	                alert("发布失败！");	            },	            success: function()	            {	                alert("发布成功！");	                window.close();	            }	        });        };
                function mailto()        {	        $.ajax({	            url:'my_pubnews_mailto.aspx',	            type:'post',	            data: "articletitle="+escape($("#articletitle").val())	        });        }                function article_preview()
        {
            if(article_chk())            {	            //var url="my_pubnews_preview.aspx?userid="+$("#myuid").val()+"&articletitle="+escape($("#articletitle").val())+"&acontent="+escape(getEditorHTMLContents("fck_content"));	            var htmlcontent=new String(getEditorHTMLContents("fck_content"));	            htmlcontent=htmlcontent.replace(/'/g,"\"");	            //alert(htmlcontent);	            var newview=window.open('','_blank');	            newview.location.href="my_pubnews_preview.aspx?userid="+$("#myuid").val()+"&articletitle="+escape($("#articletitle").val())+"&acontent="+escape(htmlcontent);	        }        };
	    	    function article_clear()	    {	        $("#articletitle").val('');	        SetEditorContents('fck_content','');	        $("#articletitle").focus();	    }	    	    function article_cancel()	    {	        if(confirm('确认是要取消发布吗？'))	        {	            window.close();	        }	    }	    $(document).ready(function(){	       $("#articletitle").Watermark("请输入内容标题,最多25个字符!");           $("#articletitle").textLimiter();	    });	</script></head>
<body>
    <form id="form1" runat="server">
    <div>
        <table border="1" cellpadding="2" cellspacing="0" style='BORDER-COLLAPSE: collapse' bordercolor="#cfdfff" width="96%" align="center">
            <tr bgcolor="#f5fafe">
                <td align="center" width="80">内容标题</td><td align="left"><input type="text" id="articletitle" maxlength="25" style="width: 400px" /></td>
            </tr>
            <tr>
                <td colspan=2><FCKeditorV2:FCKeditor ID="fck_content" runat="server" BasePath="/easycrm/fckeditor/" Height="600px" Width="100%" ToolbarSet="CMS01"></FCKeditorV2:FCKeditor></td>
            </tr>
            <tr bgcolor="#f5fafe">
                <td colspan=2><input id="btncancel" type="button" value="取消" onclick="article_cancel()" style="width: 60px;" />&nbsp;<input id="btnreset" type="button" value="重写" onclick="article_clear()" style="width: 60px;" />&nbsp;<input id="btnpreview" type="button" value="预览" onclick="article_preview()" style="width: 60px;" disabled="disabled" />&nbsp;<input id="btnsave" type="button" value="发布" onclick="article_save()" style="width: 60px;" />
                    <input id="sendmail" type="checkbox" />是否邮件群发</td>
            </tr>
        </table>
    </div>
    <div id="myhidediv" style="VISIBILITY: hidden;"><asp:TextBox ID="myuid" runat="server"></asp:TextBox></div>
    </form>
</body>
</html>
